package com.bcu.calculus.controller;

import com.bcu.calculus.config.GlobalConfig;
import com.bcu.calculus.entity.Image;
import com.bcu.calculus.entity.Message;
import com.bcu.calculus.entity.Semester;
import com.bcu.calculus.entity.SemesterNumber;
import com.bcu.calculus.service.ImageService;
import com.bcu.calculus.service.SemesterService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiModelProperty;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.text.ParseException;
import java.util.List;

@Api(tags = "09  学期模块")
@RestController
@RequestMapping("/api/Semester")
public class SemesterController {


    @Resource
    private SemesterService semesterService;

    @ApiOperation(value = "添加学期")
    @PostMapping(value = "/inster")
    public Message<?> insert(SemesterNumber semesterNumber) throws ParseException {
        return semesterService.insert(semesterNumber);
    }


    @ApiOperation(value = "通过关键字删除")
    @DeleteMapping(value = "/deleteByPrimaryKey")
    public Message deleteByPrimaryKey(Integer semId) {
        return semesterService.deleteByPrimaryKey(semId);
    }


    @ApiOperation(value = "通过主键修改")
    @PutMapping(value = "/updateByPrimaryKey")
    public Message updateByPrimaryKey(SemesterNumber semesterNumber) throws ParseException {
        return semesterService.updateByPrimaryKey(semesterNumber);
    }

    @ApiOperation(value = "通过关键字查询")
    @GetMapping(value = "/selectByPrimaryKey")
    public Message<Semester>selectByPrimaryKey(Integer semId) {
        return semesterService.selectByPrimaryKey(semId);
    }

    @ApiOperation(value = "查询所有学期")
    @GetMapping(value = "/selectAllAct")
    public Message<List<Semester>> selectAllSemester(){
        return semesterService.selectAllSemester();
    }

    @ApiOperation(value = "查看当前学期")
    @GetMapping(value = "findNowSemester")
    public Message<Semester> findNowSemester(){
        return semesterService.findNowSemster();
    }

    @ApiOperation(value = "当前是否有开放的学期")
    @GetMapping(value = "findIsNowSemester")
    public Message<Integer> findIsNowSemester(){
        return semesterService.findHaveNowSemester();
    }

}
